class ApplicationController < ActionController::Base

  include RenderTools
  include AuthenticatedSystem

  before_filter :login_from_cookie
  before_filter :before_render_tools
  before_filter :setup
  after_filter  :after_render_tools

  helper :all

  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  protect_from_forgery # :secret => 'af417f5cf215f3aa8015142911c0de40'
  
  filter_parameter_logging :password

  def setup
    if Program.count == 0
      flash[:error] = "Welcome to #{APPLICATION_NAME}. To begin, enter the name of your program."
      redirect_to new_program_path
    else
      @program = Program.find(:first)
    end
  end

end
